package com.example.myapplication_view;

import androidx.appcompat.app.AppCompatActivity;

import android.animation.ValueAnimator;
import android.os.Bundle;
import android.view.animation.DecelerateInterpolator;

public class MainActivity extends AppCompatActivity {

    //引用
    private FIWStepView fiwStepView;


    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);

        // 加入动画
        fiwStepView = findViewById(R.id.step_view);
        fiwStepView.setmMaxStep(10000);  // 设置最大步数

        ValueAnimator animator = ValueAnimator.ofFloat(0,8000);
        animator.setInterpolator(new DecelerateInterpolator());// 设置加速度效果
        animator.setDuration(1000);
        animator.addUpdateListener( (animation)->{
            float currentSteps = (float)animation.getAnimatedValue();
            fiwStepView.setmCurrentStep((int) currentSteps);
        });
        animator.start();
    }
}